package com.raymond.queue.common.handler;

import com.raymond.queue.common.msg.BaseMessage;
import com.raymond.queue.common.msg.request.ConsumptionMsgRequest;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 消费消息请求
 * 业务处理封装成公共的
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-07-17 21:52
 */
public abstract class DispatcherHandler<I extends BaseMessage> extends SimpleChannelInboundHandler<BaseMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, BaseMessage msg) throws Exception {
        @SuppressWarnings("unchecked")
        I iMsg= (I)msg;
        channelRead(ctx, iMsg);
    }

    /**
     *  消息处理
     * @param ctx ctx
     * @param msg 消息
     */
    protected abstract void channelRead(ChannelHandlerContext ctx, I msg);
}
